//日照分析
var sunAnalysis = {
    //时间比
    ftime: 0.26,
    //定时器
    sunTimer: null,
    //自动日照
    oTimeOut: null,
    ftimeNum: 0,
    switchContainer: function (obj) {
        if (obj.hasClass("active")) {
            obj.removeClass("active");
            viewer.shadows = false;
            $("#timeGet").removeClass("active");
        } else {
            page.initialStatus("sun");
            viewer.shadows = true;
            $("#timeGet").addClass("active");
            obj.parents("#switch-box").find(".bar-item").removeClass("active");
            obj.addClass("active");
        }
    },
    autoSunDelay: function () {
        sunAnalysis.sunTimer = setInterval(function () {
            if (sunAnalysis.fTime >= 1) {
                dragdealer.setValue(0, 1, false);
                sunAnalysis.fTime = 0;
            } else {
                if (Math.abs(sunAnalysis.fTime - sunAnalysis.fTimeNum) < 0.001) {
                    dragdealer.setValue(sunAnalysis.fTimeNum, 1, false);
                    clearInterval(sunAnalysis.sunTimer);
                    sunAnalysis.fTime = sunAnalysis.fTimeNum;
                    $("#autoSun").removeClass("active");
                    //setTimeout(function(){dragdealer.setValue(0.25,1,false);},2000);
                } else {
                    dragdealer.setValue(sunAnalysis.fTime, 1, false);
                    sunAnalysis.fTime = sunAnalysis.fTime + 0.01;
                }
            }
        }, 100);
    },
    init: function () {
        //日照分析用
        var julianDay, julianSecound;
        var date_init;
        date_init = new Date();
        date_init.setHours(14);
        date_init.setMinutes(30);

        dragdealer = new Dragdealer('demo-simple-slider', {
            x: getNowFormatDate(date_init).number,
            left: -11,
            right: -11,
            css3: false,
            speed: 1,
            animationCallback: function (x, y) {
                $(".content-body").css({ 'width': Math.ceil(376 * x) + 'px' });
                var hour = Math.floor(24 * x);
                var minute = Math.floor((24 * x - hour) * 60);
                var secound = Math.floor(((24 * x - hour) * 60 - minute) * 60);

                $(".timeBox").html(hour + ' : ' + minute + ' ： ' + secound);

                if (julianDay) {
                    //如果选择了年月日
                    julianSecound = hour * 60 * 60 + minute * 60 + secound;
                } else {
                    //如果没有选择年月日，就是现在的年月日
                    var nowCalender = getNowFormatDate().nowData;

                    var JulianDate = computes(nowCalender);
                    julianDay = JulianDate;
                    julianSecound = hour * 60 * 60 + minute * 60 + secound;
                }
                //console.log(julianSecound);
                if (julianSecound >= 28800) {
                    viewer.clock.currentTime = new LSGlobe.JulianDate(julianDay, julianSecound - 28800);
                } else {
                    viewer.clock.currentTime = new LSGlobe.JulianDate(julianDay - 1, julianSecound + 57600);
                }

            }
        });


        //打开日照分析 
        $("#SunAnalysis").on("click", function () {
            disabledDantihua(false);
            sunAnalysis.switchContainer($(this));
        });

        $("#autoSun").click(function () {
            sunAnalysis.fTime = parseFloat(dragdealer.getValue()[0]).toFixed(2);

            sunAnalysis.fTimeNum = sunAnalysis.fTime;
            sunAnalysis.fTime = parseFloat(sunAnalysis.fTime) + 0.01;
            if ($(this).hasClass("active")) {
                clearTimeout(sunAnalysis.oTimeOut);
                clearInterval(sunAnalysis.sunTimer);
                $(this).removeClass("active");
            } else {
                dragdealer.setValue(sunAnalysis.fTime, 0, false);
                clearInterval(sunAnalysis.sunTimer);
                setTimeout(sunAnalysis.autoSunDelay, 100);
                $(this).addClass("active");
            }

        });

        //选择日期
        $('.dayContral').on('click', function () {
            if (!$(this).attr("clicked") || $(this).attr("clicked") == "0") {
                $('.calenderShow').trigger("mousedown");
                $(this).attr("clicked", 1);
            } else {
                $(this).attr("clicked", 0);
                $("#ProImg").mousedown();
            }
        });
        $(".dayBox").html(getNowFormatDate().currentDate);
        $('.calenderShow').datetimepicker({
            timepicker: false,
            formatDate: 'Y/m/d',
            format: 'd/m/Y',
            changeMonth: true,
            changeYear: true,
            dateFormat: 'yy-MM',
            showButtonPanel: true,
            onClose: function (dateText, inst) {
                var calender = dateText;

                $(".dayBox").html(getNowFormatDate(calender).currentDate);

                var JulianDate = computes(calender);
                julianDay = JulianDate;
                viewer.clock.currentTime = new LSGlobe.JulianDate(julianDay, julianSecound - 28800);
            }
        });
    }
}


/********************  可视域分析    ***********************/
var viewAnalysis = {
    switchContainer: function (obj) {
        var oThis = obj;
        if (oThis.hasClass("active")) {
            oThis.removeClass("active");
            $("#viewAnalysis-container").hide();
        } else {
            page.initialStatus("ViewAnalysis");
            $("#viewAnalysis-container").show();
            oThis.parents("#switch-box").find(".bar-item").removeClass("active");
            oThis.addClass("active");
        }
    },
    closeContainer: function () {
        $("#viewAnalysis-container").hide();
        $("#").removeClass("active");
    },
    clearviewAnalysis: function () {
        //清空可视区域
        for (var i = 0; i < aViewshed3d.length; i++) {
            try {
                viewer.scene.primitives.remove(aViewshed3d[i]);
            } catch (e) { }
        }
        p_viewshed3d = undefined;
        aViewshed3d = [];
    },
    doAnalysis: function () {
        //可视分析
        /*if(!viewAnalysisDataSource){
        var promise = viewer.dataSources.add(new LSGlobe.GeoJsonDataSource("viewAnalysisDataSource"));
        promise.then(function(dataSource) {
        viewAnalysisDataSource = dataSource;
        }).otherwise(function(error){

        });
        }
        targetDataSource = viewAnalysisDataSource;*/
        viewshed3d = new LSGlobe.LSViewshed3D(viewer);
        //p_viewshed3d._childViewsheds.push(viewshed3d);
        //viewshed3d._parentViewshed = p_viewshed3d;
        //p_viewshed3d.attachViewshed(viewshed3d);

        if (p_viewshed3d) {
            p_viewshed3d.attachViewshed(viewshed3d);
        } else {
            p_viewshed3d = viewshed3d;
        }

        aViewshed3d.push(viewshed3d);
        viewshed3daction = true;
        viewshed3ding = false;
    },
    whichTileset: function (x, y) {
        //判断点击点是否在模型上 
        /* x,y 点击点的经纬度   */
        var returnValue = "";
        for (var i = 0; i < viewer.scene.primitives.length; i++) {
            var aTileSet = viewer.scene.primitives.get(i);
            if (aTileSet._type == "pageLOD") {
                var position = aTileSet._position;
                var distance = viewAnalysis.getDistance(position, x, y);
                if (distance < aTileSet._boundingSphere.radius) {
                    returnValue = aTileSet;
                }
            }
        }
        return returnValue;
    },
    getDistance: function (position, x, y) {
        /* var DTOR = ; */
        /*  position   倾斜模型的 aTileSet._position xy点击点的经纬度  */
        var radLatA = position.y * 0.0174532925199432957692369077;
        var radLatB = y * 0.0174532925199432957692369077;
        var radLonA = position.x * 0.0174532925199432957692369077;
        var radLonB = x * 0.0174532925199432957692369077;
        return Math.acos(
					Math.cos(radLatA) * Math.cos(radLatB) * Math.cos(radLonA - radLonB) +
					Math.sin(radLatA) * Math.sin(radLatB)) * 6378137;

    },
    init: function () {
        //可视域分析图表点击
        $("#ViewAnalysis").on("click", function () {
            viewAnalysis.switchContainer($(this));
        });
        //关闭可视域分析
        $("#viewAnalysis-container .comment-close").on("click", function () {
            viewAnalysis.closeContainer();
        });
        //创建可视分析
        $("#btnCreateViewAnalysis").click(function () {
            //可视分析
            viewAnalysis.doAnalysis();
        });
        $("#cancelAnalysis").click(function () {
            viewAnalysis.clearviewAnalysis(); // 清空可视域

            viewshed3daction = false;
            viewshed3ding = false;
        });
    }
}


//模型方量分析
volumeAnalysis = {
    leftClick: function (movement) {
        /**************** 方量分析 ******************/
        var cartesian = viewer.camera.pickEllipsoid(movement.position, scene.globe.ellipsoid);
        if (cartesian && isrange) {
            var cartographic = LSGlobe.Cartographic.fromCartesian(cartesian);
            var currentClickLon = LSGlobe.Math.toDegrees(cartographic.longitude).toFixed(2);
            var currentClickLat = LSGlobe.Math.toDegrees(cartographic.latitude).toFixed(2);
            var posit = scene.pickPosition(movement.position);
            if (LSGlobe.defined(posit)) {
                var cartographic = LSGlobe.Cartographic.fromCartesian(posit);
            }
            currentClickLon = LSGlobe.Math.toDegrees(cartographic.longitude);
            currentClickLat = LSGlobe.Math.toDegrees(cartographic.latitude);
            var CurrentTileSet = viewAnalysis.whichTileset(currentClickLon, currentClickLat);

            if (CurrentTileSet == "") {
                isNotInTileSet = true;
                $("#float-tip").html("请依附模型进行操作");
                setTimeout(function () {
                    isNotInTileSet = false;
                }, 1500);
                return;
            } else {
                if (!analysisTileset) {
                    analysisTileset = CurrentTileSet;
                    tileset = CurrentTileSet;
                    setInterval(volumeAnalysis.getProgress, 3000);
                } else {
                    if (analysisTileset.name.guid != CurrentTileSet.name.guid) {
                        isSameTileset = true;
                        $("#float-tip").html("请在同一个模型上进行分析")
                        setTimeout(function () {
                            isSameTileset = false;
                        }, 1500);
                        return;
                    }
                }
            }
            var currentClickHei = cartographic.height;
            if (!isStartDraw) {
                //特别注意_actionCutFill：true是支持橡皮筋绘制，isrange：true是传统绘制
                if (isPolygon_fill) {
                    tempDataSource.entities.add({
                        position: cartesian,
                        clampToGround: true,
                        attachPolygon: true,
                        point: {
                            parent: points,
                            pixelSize: 3,
                            color: LSGlobe.Color.YELLOW,
                            disableDepthTestDistance: 1000000000//优先级
                        }
                    });

                    firstPointLon = currentClickLon;
                    firstPointLat = currentClickLat;
                    firstPointHei = currentClickHei;

                    PolygonPointArray_fill = null;
                    isStartDraw = true;
                    CommobPolygonHeight = currentClickHei;
                }
            } else {

                if (isPolygon_fill) {
                    tempDataSource.entities.add({
                        position: cartesian,
                        clampToGround: true,
                        attachPolygon: true,
                        point: {
                            parent: points,
                            pixelSize: 3,
                            color: LSGlobe.Color.YELLOW,
                            disableDepthTestDistance: 1000000000//优先级
                        }
                    });
                    tempDataSource.entities.add({
                        name: 'line on the surface',
                        parent: polylines,
                        clampToGround: true,
                        attachPolygon: true,
                        polyline: {
                            positions: LSGlobe.Cartesian3.fromDegreesArrayHeights([lastPointLon, lastPointLat, lastPointHei, currentClickLon, currentClickLat, currentClickHei]),
                            width: 2,
                            material: LSGlobe.Color.BLUE,
                            clampToGround: true,
                            attachPolygon: true,
                            disableDepthTestDistance: 1000000000//优先级
                        }
                    });
                }
                currentClickHei = CommobPolygonHeight;
            }

            //记录鼠标点击的当前位置 作为下一次画线的起始点位置
            lastPointLon = currentClickLon;
            lastPointLat = currentClickLat;
            lastPointHei = currentClickHei;

            if (PolygonPointArray_fill == null)
                PolygonPointArray_fill = new Array();
            PolygonPointArray_fill.push(currentClickLon);
            PolygonPointArray_fill.push(currentClickLat);
            PolygonPointArray_fill.push(currentClickHei);


            if (_actionFlatPolygon || _actionCutFill || isrange) {
                var cartesian = viewer.scene.pickPosition(movement.position);
                poinsTemp.push(cartesian);
            }
        }
    },
    rightClick: function (movement) {
        /************** 方量分析 *******************/
        if (isPolygon_fill) {
            var cartesian = viewer.camera.pickEllipsoid(movement.position, scene.globe.ellipsoid);
            if (cartesian && isStartDraw) {
                var cartographic = LSGlobe.Cartographic.fromCartesian(cartesian);
                var endPointLon = LSGlobe.Math.toDegrees(cartographic.longitude).toFixed(2);
                var endPointLat = LSGlobe.Math.toDegrees(cartographic.latitude).toFixed(2);
                var posit = scene.pickPosition(movement.position);
                if (LSGlobe.defined(posit)) {
                    var cartographic = LSGlobe.Cartographic.fromCartesian(posit);
                }

                var currentClickLon = LSGlobe.Math.toDegrees(cartographic.longitude);
                var currentClickLat = LSGlobe.Math.toDegrees(cartographic.latitude);
                var currentClickHei = cartographic.height;
                currentClickHei = CommobPolygonHeight;
                endPointLon = currentClickLon;
                endPointLat = currentClickLat
                var endPointHei = currentClickHei;


                //画面 多边形带填充

                if (PolygonPointArray_fill != null) {
                    //PolygonPointArray_fill.push(endPointLon);
                    //PolygonPointArray_fill.push(endPointLat);
                    //PolygonPointArray_fill.push(endPointHei);
                }
                var id = "impolygon";
                //当面中点的个数大于等于3时添加面
                if (PolygonPointArray_fill.length >= 9) {
                    if (isrange) {  // 模型方量分析
                        targetDataSource.entities.add({
                            name: '未命名面',
                            id: id,
                            polygon: {
                                hierarchy: LSGlobe.Cartesian3.fromDegreesArrayHeights(PolygonPointArray_fill),
                                material: new LSGlobe.Color(0.5, 1.0, 1.0, 0.7),
                                fill: true,  //不显示填充
                                outline: true,
                                outlineColor: LSGlobe.Color.YELLOW,
                                perPositionHeight: true
                            }
                        });
                        //poinsTemp.push(posit);
                        isrange = false;
                        $("#float-tip").hide();
                        tempDataSource.entities.removeAll();
                        $("#basicPolygonH").val(parseInt(endPointHei));
                        analysisTileset = "";
                    }

                    PolygonPointArray_fill = null;
                    isPolygon_fill = false;

                    isStartDraw = false;
                    $("#CreateAnalysis").removeAttr("disabled").removeClass("disabled").html("重置分析范围");
                    $(".analysisBox").eq(0).removeClass("hidden");
                } else {
                    $("#float-tip").hide();
                    alert("绘制范围最少3个点");

                }

            } else {
                PolygonPointArray_fill = null;
                isPolygon_fill = false;
                tempDataSource.entities.removeAll();
                targetDataSource.entities.removeAll();
                $("#CreateAnalysis").removeAttr("disabled").removeClass("disabled");
                isrange = false;
                $("#float-tip").hide();
            }
        }
    },
    mouseMove: function (movement) {
        /************** 方量分析  *******************/
        if (_actionFlatPolygon || _actionCutFill) {
            var cartesian = viewer.scene.pickPosition(movement.endPosition);
            if (poinsTemp.length > 2) {
                poinsTemp[poinsTemp.length - 1] = cartesian;
            }
        }
    },
    switchContainer: function (obj) {
        var oThis = obj;
        if (oThis.hasClass("active")) {
            oThis.removeClass("active");
            $("#VolumeAnalysis-container").hide();
        } else {
            page.initialStatus("VolumeAnalysis");
            $("#VolumeAnalysis-container").show();
            oThis.parents("#switch-box").find(".bar-item").removeClass("active");
            oThis.addClass("active");
        }
    },
    closeContainer: function () {
        $("#VolumeAnalysis-container").hide();
        $("#VolumeAnalysis").removeClass("active");
    },
    drawRange: function () {
        // 设置范围
        if (!rangeDataSource) {
            var promise = viewer.dataSources.add(new LSGlobe.GeoJsonDataSource("rangeDataSource"));
            promise.then(function (dataSource) {
                rangeDataSource = dataSource;
            }).otherwise(function (error) {

            });
        } else {
            rangeDataSource.entities.removeAll();
        }
        targetDataSource = rangeDataSource;
        isPolygon_fill = true;
        isrange = true;
        tempDataSource.show = true;
    },
    getProgress: function () {
        nodeMesh = tileset.NodeMesh;
        //console.log(tileset.NodeMesh);
    },
    computeProgress: function () {
        //分析结果
        //填方体积
        var fillvolume = cutfill.fillVolume.toFixed(3);
        //挖方体积
        var cutvolume = cutfill.cutVolume.toFixed(3);
        $("#tianfang").html("填方体积：" + fillvolume + "立方米");
        $("#wafang").html("挖方体积：" + cutvolume + "立方米");
        $(".analysisBox").eq(1).removeClass("hidden");
        //删除loading
        removeLoading('viewAnalysis');
    },
    analysisLoading: function () {
        $('body').loading({
            loadingWidth: 240,
            title: '请稍等!',
            name: 'viewAnalysis',
            discription: '加载分析结果',
            direction: 'column',
            type: 'origin',
            // originBg:'#71EA71',
            originDivWidth: 40,
            originDivHeight: 40,
            originWidth: 6,
            originHeight: 6,
            smallLoading: false,
            loadingMaskBg: 'rgba(0,0,0,0.2)'
        });
    },
    modelAnalysis: function () {
        cutfill.clear();
        volumeAnalysis.analysisLoading();

        cutfill.completeEvent.addEventListener(volumeAnalysis.computeProgress);

        var cartographic = LSGlobe.Cartographic.fromCartesian(poinsTemp[0]);

        cutfill.vertice = nodeMesh; //tileset.NodeMesh;
        console.log(tileset);
        cutfill.matLocal = tileset.m_matLocal;
        LSGlobe.Matrix4.inverseTransformation(tileset.m_matLocal, cutfill.matLocalInvert);


        //分析的面高度
        var height = $("#basicPolygonH").val();
        if (height) {
            cutfill.zFactor = height;
        } else {
            cutfill.zFactor = cartographic.height;
        }

        //分析的面对象
        var Mypolygon = new LSGlobe.PolygonGeometry({
            polygonHierarchy: new LSGlobe.PolygonHierarchy(poinsTemp),
            perPositionHeight: true
        });
        cutfill.polygon = Mypolygon;
        //采样间隔
        var interval = $(".v-analysis-deg input:checked").val();
        console.log(interval);
        cutfill.sampleGap = interval;

        //执行分析
        cutfill.apply();

        $("#StartAnalysis").html("重新分析");
    },
    clearAnalysis: function () {
        cutfill.clear();
        rangeDataSource.entities.removeAll();
        $(".analysisBox").addClass("hidden");
        $("#CreateAnalysis").html("创建分析范围");
        $("#StartAnalysis").html('<img src="../images/shuju.png" alt="" />开始分析');
    },
    init: function () {
        //打开方量分析
        $("#VolumeAnalysis").on("click", function () {
            disabledDantihua(false);
            volumeAnalysis.switchContainer($(this));
        });
        //关闭方量分析
        $("#VolumeAnalysis-container .comment-close").on("click", function () {
            volumeAnalysis.closeContainer();
        });


        //创建分析范围
        $("#CreateAnalysis").click(function () {
            $(".analysis").hide();
            if (cutfill) {
                cutfill.clear();
            }
            //_actionCutFill = true;
            //绘制范围
            volumeAnalysis.drawRange();
            poinsTemp = [];
            $(this).attr("disabled", "disabled").addClass("disabled");
            $(".analysisBox").addClass("hidden");
            $("#StartAnalysis").html('<img src="../images/shuju.png" alt="" />开始分析');
        });


        //接口传入一个面对象
        cutfill = new LSGlobe.LSCutFill(viewer);
        //开始分析
        $("#StartAnalysis").click(function () {
            if (cutfill) {
                cutfill.clear();
            }
            volumeAnalysis.modelAnalysis();
        });

        //清空分析
        $("#ClearAnalysis").click(function () {
            poinsTemp = [];
            cutfill.clear();
            volumeAnalysis.clearAnalysis();
        });


        //基准面高文本框
        $("#basicPolygonH").on("change keyup", function () {
            // targetDataSource.entities.getById("impolygon").polygon.height=$(this).val();
            if ($.trim($(this).val()) == "") { return; }
            if (rangeDataSource) {
                var entities = rangeDataSource.entities.values;
                var pointArray = [];
                for (var i = 0; i < entities.length; i++) {
                    var entity = entities[i];
                    if (entity.polygon) {
                        var points = entity.polygon.hierarchy._value;
                        for (var j = 0; j < points.length; j++) {
                            var p = points[j];
                            var cartographic = LSGlobe.Cartographic.fromCartesian(p);
                            pointArray.push(LSGlobe.Math.toDegrees(cartographic.longitude));
                            pointArray.push(LSGlobe.Math.toDegrees(cartographic.latitude));
                            pointArray.push($("#basicPolygonH").val());
                        }
                        entity.polygon.material = LSGlobe.Color.fromRandom({
                            alpha: 0.01
                        });
                    }
                }
                rangeDataSource.entities.removeAll();
                rangeDataSource.entities.add({
                    name: '未命名面',
                    id: "impolygon",
                    polygon: {
                        hierarchy: LSGlobe.Cartesian3.fromDegreesArrayHeights(pointArray),
                        material: new LSGlobe.Color(0.5, 1.0, 1.0, 0.7),
                        fill: true,  //不显示填充
                        perPositionHeight: true
                    }
                });
            }
        });
    }
}


var analysis = {
    init: function () {
        //分析 前台点击逻辑 
        $("#btnShowAnalysis").on("click", function () {
            page.initialStatus("analysisType");
            if ($(this).parent().hasClass("active")) {
                $(this).parent().removeClass("active");
                $(this).parent().find(".analysis").hide();
            } else {
                $(this).parent().parents("#switch-box").find(".bar-item").removeClass("active");
                $(this).parent().addClass("active");
                $(this).parent().find(".analysis").show();
            }
        });

        //鼠标点击
        $("canvas").mousemove(function (e) {
            $("#flyBotttom .flySelect ul").hide();
            var floatTip = $("#float-tip");
            if (isCoordinate) {
                floatTip.html("左击测量").css({ left: e.clientX + 15 + "px", top: e.clientY + "px" });
                floatTip.show();
            } else if (heightMeasure && heightMeasure.enable) {
                floatTip.html("左击测量，再次点击结束").css({ left: e.clientX + 15 + "px", top: e.clientY + "px" });
                floatTip.show();
            } else if ((distance && distance.enable) || (areaMeasure && areaMeasure.enable)) {
                floatTip.html("左击测量，右击结束").css({ left: e.clientX + 15 + "px", top: e.clientY + "px" });
                floatTip.show();
            } else if (viewshed3daction) {
                /* if(!isNotInTileSet){
                floatTip.html("请依附模型进行操作").css({left:e.clientX+15+"px",top:e.clientY+"px"});
                floatTip.show();
                return;
                }else if(isSameTileset){
                floatTip.html("请在同一个模型上进行分析").css({left:e.clientX+15+"px",top:e.clientY+"px"});
                floatTip.show();
                return;
                } */
                floatTip.html("点击绘制3D可视域分析").css({ left: e.clientX + 15 + "px", top: e.clientY + "px" });
                floatTip.show();
            } else if (isrange) {
                if (isNotInTileSet) {
                    floatTip.html("请依附模型进行操作").css({ left: e.clientX + 15 + "px", top: e.clientY + "px" });
                    floatTip.show();
                    return;
                } else if (isSameTileset) {
                    floatTip.html("请在同一个模型上进行分析").css({ left: e.clientX + 15 + "px", top: e.clientY + "px" });
                    floatTip.show();
                    return;
                }
                floatTip.html("左击绘制分析范围，右击结束").css({ left: e.clientX + 15 + "px", top: e.clientY + "px" });
                floatTip.show();
            } else {
                floatTip.hide();
            }
        }).click(function () {
            /* var floatTip=$("#float-tip");
            floatTip.hide();  */
        });

        //日照分析
        sunAnalysis.init();
        //可视域分析
        viewAnalysis.init();
        //模型方量分析
        volumeAnalysis.init();
    }
}



function getNowFormatDate(newDate) {
    var date;
    if (newDate) {
        date = newDate;
    } else {
        date = new Date();
    }
    var seperator1 = "-";
    var month = date.getMonth() + 1;
    var strDate = date.getDate();
    if (month >= 1 && month <= 9) {
        month = "0" + month;
    }
    if (strDate >= 0 && strDate <= 9) {
        strDate = "0" + strDate;
    }
    var currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate
    var Number = (date.getHours() * 60 * 60 + date.getMinutes() * 60 + date.getSeconds()) / (24 * 60 * 60);
    return {
        nowData: date,
        number: Number,
        secound: date.getHours() * 60 * 60 + date.getMinutes() * 60 + date.getSeconds(),
        currentDate: currentdate
    };
}


function computes(now) {
    var month = now.getUTCMonth() + 1;
    var day = now.getUTCDate();
    var year = now.getUTCFullYear()

    var y = eval(year);
    var m = eval(month);
    var d = eval(day);
    var extra = 100.0 * y + m - 190002.5;
    var rjd = 367.0 * y;
    rjd -= Math.floor(7.0 * (y + Math.floor((m + 9.0) / 12.0)) / 4.0);
    rjd += Math.floor(275.0 * m / 9.0);
    rjd += d;
    rjd += 1721013.5;
    rjd -= 0.5 * extra / Math.abs(extra);
    rjd += 0.5;
    return rjd;
}

$(".radio-img").on("click", function () {
    var oThis = $(this);
    $(".radio-img").attr('src', '../images/weixuanzhong.png');
    oThis.attr('src', '../images/xuanzhong.png');
    $(".radio-img").prev().removeAttr("checked")
    oThis.prev().attr("checked", 'true');
    
})